package android.FiltrosJava;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;

public class DrawWhiteBorder extends AbstractImageBasic{
	int bgR, bgG, bgB;
	public DrawWhiteBorder(){
		setBackgroundColor(255,255,255);		
	}
	public DrawWhiteBorder(int R, int G, int B){
		setBackgroundColor(R, G, B);		
	}
	
	public void setBackgroundColor(int R, int G, int B){
		bgR = R;
		bgG = G;
		bgB = B;		
	}
	
	public BufferedImage applyFilter(BufferedImage src) {
		/*
		int menor = Math.min(src.getWidth(), src.getHeight());
		menor = (int) (menor / 10.0f);
		if (menor < 10)
			menor = 10;
		
		BufferedImage p = new BufferedImage( src.getWidth()+menor, src.getHeight()+menor, BufferedImage.TYPE_INT_RGB);
		Graphics2D g = p.createGraphics();
		g.fillRect(0, 0, src.getWidth()+menor, src.getHeight()+menor);
		menor = (int) (menor /2.0f);
		g.drawImage( src, menor, menor, null );
		g.dispose();
		return p;
		*/
				
		int px = (int) (src.getWidth() / 20.0f);
		int py = (int) (src.getHeight() / 20.0f);
		ScaleTransform f = new ScaleTransform(0.9f,0.9f);				
		BufferedImage p = f.applyFilter(src);
		f = null;
		
		Graphics2D g = src.createGraphics();
		g.setPaint(new Color(bgR,bgG,bgB));
		g.fillRect(0, 0, src.getWidth(), src.getHeight());		
		g.drawImage( p, px, py, null );
		p = null;
		g.dispose();
		return src;		
	}
}
